set.seed(1)
data(instacart)

Column

Histogram of Number of Items per Order

instacart %>% 
  group_by(order_id) %>% 
  mutate(  #add column for number of items in order
    n_items = n()
  ) %>% 
  plot_ly(x = ~n_items, type = "histogram") %>% 
  layout(
    title = "Distribution of Number of Items per Order",
    xaxis = list(title = "# Items"),
    yaxis = list(title = "Orders")
  )

Column

Boxplot of Order Times in Top Departments

top_departments =
  instacart %>% 
  count(department, sort = TRUE) %>% 
  top_n(6)
## Selecting by n
inner_join(instacart, top_departments, by = "department") %>%
  
  plot_ly(y = ~order_hour_of_day, color = ~department, 
          type = "box", colors = "Set2") %>% 
  layout(
    title = "Order Times for Top 6 Departments",
    xaxis = list(title = "Department"),
    yaxis = list(title = "Hour of Day")
  )